﻿@{
    Layout = null;
    var tree_org_formatter = PageViewModel.PageFunctionName(this, "tree_org_formatter");
    var on_before_select_fun = PageViewModel.PageFunctionName(this, "on_before_select_fun");
    var on_before_check_fun = PageViewModel.PageFunctionName(this, "on_before_check_fun");
    var on_main_dept_changed = PageViewModel.PageFunctionName(this, "on_main_dept_changed");
    var on_subsidiary_dept_changed = PageViewModel.PageFunctionName(this, "on_subsidiary_dept_changed");
    var on_subsidiary_ShowPanel = PageViewModel.PageFunctionName(this, "on_ShowPanel");
}

<form>
    <script type="text/javascript">
        function @tree_org_formatter (node) {
            if (node.NodeType == 'ORG') {
                return "<div style='color:#cdcdcd'>" + node.text + "</div>";
            }
            return node.text;
        }

        function @on_before_select_fun (node) {
            if (node.NodeType == 'ORG') {
                $(this).tree('unselect');
            }
        }

        function @on_before_check_fun (node, checked) {
            if (node.NodeType == 'ORG') {
                return false;
            }
        }

        function @on_main_dept_changed (newValue, oldValue) {
            var form = $(this).parents("form");
            var positionList = form.find("#MainPositionID");
            positionList.combobox('reload', "~/Positions/GetPositionByDeptID/" + newValue + "?Enable=true");
            if (oldValue != "") {
                positionList.combobox('setValue', "");
            }
            form.find("#SubsidiaryDepartmentID").combotree("setValues", []);
            form.find("#SubsidiaryPositionID").combobox("setValues", []);
        }

        function @on_subsidiary_dept_changed (newValue, oldValue) {
            var positionList = $(this).parents("form").find("#SubsidiaryPositionID");
            positionList.combobox('reload', "~/Positions/GetPositionByDeptID/" + newValue + "?Enable=true");
            if (oldValue != "") {
                positionList.combobox('setValue', "");
            }
        }

        function @on_subsidiary_ShowPanel () {
            var form = $(this).parents("form");
            var selectedDepartment = form.find("#MainDepartmentID").combotree("getValue");
            var positionList = form.find("#SubsidiaryDepartmentID");
            positionList.combotree('reload', "~/Departments/GetDepartmentFullTree?Enable=true&NOT_ID=" + selectedDepartment);
        }

    </script>
    <table class="form_table">
        <tr>
            <td width="150" align="right">启用登录：</td>
            <td>
                <input name="Id" style="display:none" value="" />
                <input id="Enable" name="Enable" class="easyui-switchbutton" checked data-options="onText:'是',offText:'否'" style="width:100px;height:25px;" />
            </td>
            <td width="150" align="right">密码：</td>
            <td>
                <input id="PasswordHash" name="PasswordHash" class="easyui-passwordbox" data-options="showEye:true" style="width:280px;" />
            </td>
        </tr>
        <tr>
            <td width="150" align="right">系统登录名：</td>
            <td>
                <input name="UserName" class="easyui-textbox" style="width:280px;" data-options="required:true" />
            </td>
            <td align="right">账户类型：</td>
            <td>
                <select name="UserType" class="easyui-combobox" style="width:100px" data-options="editable:false,value:'1',method:'get',url:'~/Systems/GetAppDictionary/USER_TYPE',valueField:'DictionaryID',textField:'Name'"></select>
                <span style="margin-left:30px">账户状态：</span>
                <select name="Status" class="easyui-combobox" style="width:70px" data-options="editable:false,value:'1',method:'get',url:'~/Systems/GetAppDictionary/USER_STATUS',valueField:'DictionaryID',textField:'Name'"></select>
            </td>
        </tr>
        <tr>
            <td align="right">人员编号：</td>
            <td>
                <input name="Code" class="easyui-textbox" style="width:280px;" />
            </td>
            <td align="right">姓名拼音：</td>
            <td>
                <input name="FullNameCode" class="easyui-textbox" style="width:280px;" />
            </td>
        </tr>
        <tr>
            <td align="right">姓名：</td>
            <td>
                <input name="FullName" class="easyui-textbox" style="width:280px;" data-options="required:true" />
            </td>
            <td align="right">
                性别：
            </td>
            <td>
                <select name="Gender" class="easyui-combobox" style="width:100px" data-options="editable:false,value:'男'">
                    <option value="男" selected="selected">男</option>
                    <option value="女">女</option>
                </select>
            </td>
        </tr>
        <tr>
            <td align="right">
                主部门：
            </td>
            <td>
                <input id="MainDepartmentID" name="MainDepartmentID" class="easyui-combotree" style="width:280px"
                       data-options="url:'~/Departments/GetDepartmentFullTree?Enable=true',method:'get',editable:false,valueField:'Id',textField:'FullName',
                                     formatter:@tree_org_formatter,
                                     onBeforeSelect:@on_before_select_fun,
                                     onChange:@on_main_dept_changed" />
            </td>
            <td align="right">
                职称：
            </td>
            <td>
                <input name="Title" class="easyui-textbox" style="width:280px;" />
            </td>
        </tr>
        <tr>
            <td align="right">
                主岗位：
            </td>
            <td>
                <input id="MainPositionID" name="MainPositionID" class="easyui-combobox" style="width:280px"
                       data-options="method:'get',editable:false,valueField:'Id',textField:'Name'" />
            </td>
            <td align="right">
                联系地址：
            </td>
            <td>
                <input name="Address" class="easyui-textbox" style="width:280px;" />
            </td>
        </tr>
        <tr>
            <td align="right">联系电话：</td>
            <td>
                <input name="PhoneNumber" class="easyui-textbox" style="width:280px;" />
            </td>
            <td align="right">邮件：</td>
            <td>
                <input name="Email" class="easyui-textbox" style="width:280px;" />
            </td>
        </tr>
        <tr>
            <td align="right">辅部门：</td>
            <td>
                <input id="SubsidiaryDepartmentID" name="SubsidiaryDepartmentID" class="easyui-combotree" style="width:280px"
                       data-options="url:'~/Departments/GetDepartmentFullTree?Enable=true',method:'get',editable:false,valueField:'Id',textField:'FullName',multiple:true,
                                     formatter:@tree_org_formatter,
                                     onBeforeSelect:@on_before_select_fun,
                                     onBeforeCheck: @on_before_check_fun,
                                     onChange:@on_subsidiary_dept_changed,
                                     onShowPanel:@on_subsidiary_ShowPanel" />
            </td>
            <td align="right" rowspan="2">
                备注：
            </td>
            <td rowspan="2">
                <input name="Remark" class="easyui-textbox" style="width:280px;height:80px" maxlength="512" data-options="multiline:true" />
            </td>
        </tr>
        <tr>
            <td align="right">辅岗位：</td>
            <td>
                <input id="SubsidiaryPositionID" name="SubsidiaryPositionID" class="easyui-combobox" style="width:280px"
                       data-options="method:'get',editable:false,multiple:true,valueField:'Id',textField:'Name'" />
            </td>
        </tr>

    </table>
</form>
